﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvcEngine.Core.Validation;
using MvcEngine.Core.Base;

namespace MvcEngine.Contact.Models
{
    public class ContactSettings : Entity
    {
        public ContactSettings()
        {

        }

        public ContactSettings(Entity entity)
            : base(entity)
        {

        }

        [RequiredFieldValidator("$RequiredValidator")]
        public string SendTo
        {
            get { return (string)Fields.GetValue("SendTo"); }
            set { Fields.SetValue("SendTo", value); }
        }

        [LengthValidator("$LengthValidator", 256)]
        public string EmailSubjectPrefix
        {
            get { return (string)Fields.GetValue("EmailSubjectPrefix"); }
            set { Fields.SetValue("EmailSubjectPrefix", value); }
        }

        [LengthValidator("$LengthValidator", 256)]
        [RegularExpressionValidator("$EmailValidator", "$EmailRegexExpression", true)]
        [RequiredFieldValidator("$RequiredValidator")]
        public string Email
        {
            get { return (string)Fields.GetValue("Email"); }
            set { Fields.SetValue("Email", value); }
        }

        [LengthValidator("$LengthValidator", 256)]
        [RequiredFieldValidator("$RequiredValidator")]
        public string SmtpPassword
        {
            get { return (string)Fields.GetValue("SmtpPassword"); }
            set { Fields.SetValue("SmtpPassword", value); }
        }

        [LengthValidator("$LengthValidator", 256)]
        [RequiredFieldValidator("$RequiredValidator")]
        public string SmtpServer
        {
            get { return (string)Fields.GetValue("SmtpServer"); }
            set { Fields.SetValue("SmtpServer", value); }
        }

        [RequiredFieldValidator("$RequiredValidator")]
        public int SmtpServerPort
        {
            get { return GetValue<int>("SmtpServerPort", 25); }
            set { Fields.SetValue("SmtpServerPort", value); }
        }

        [LengthValidator("$LengthValidator", 256)]
        [RequiredFieldValidator("$RequiredValidator")]
        public string SmtpUserName
        {
            get { return (string)Fields.GetValue("SmtpUserName"); }
            set { Fields.SetValue("SmtpUserName", value); }
        }

        public override string Xml { get; set; }
    }
}
